<!doctype html>
<html lang="en">
  <head>
    <title>湖南省主要珍稀植物管理信息系统</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <link rel="stylesheet" href="css/common.css">
  </head>
  <script src="./js/allData.js"></script>
  <script src="./js/vue.js"></script>
  <style>
      li a{
          line-height: 50px;
          font-size: 20px;
          color: white;
      }
  </style>
  <body style="background-image: url(img/14.jpg);background-size: 100% 100%;">
    <div id="navigator">
        <a id="systemName" href="index.html" style="color: white;">
            <b>湖南省主要珍稀植物管理信息系统</b>
        </a>
        
    </div>
    <div class="container-fluid pt-3 mt-2">
        <div class="row">
            <div  id="nav-side" class="col-md-2 pl-0 ml-0">
                <ul class="nav flex-column navbar-dark pl-0 ml-3" >
                    <!-- 带下拉的导航 -->
                    <li class="nav-item">
                        <a href="index.html" class="nav-link">首页</a>
                    </li>
                    <li class="nav-item">
                        <a href="dynamics.html" class="nav-link">保护动态</a>
                    </li>
                    <li class="nav-item">
                        <a href="policy.html" class="nav-link">政策法规</a>
                    </li>
                    

                    <li class="nav-item dropdown ">
                        <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">用户管理</a>
                        <div class="dropdown-menu">
                            <a class="dropdown-item" href="user.html">查看用户</a>
                            <a class="dropdown-item" href="adduser.html">添加用户</a>
                        </div>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">植物管理</a>
                        <div class="dropdown-menu">
                            <a class="dropdown-item" href="plant.html">查看植物</a>
                            <div class="dropdown-divider"></div>
                            <a class="dropdown-item" href="addplant.html">添加植物</a>
                        </div>
                    </li>
                </ul>
            </div>
            <div id="app" class="pl-3 ml-3 col-md-9">
                <!-- 用户添加 -->
               <form id="form" style="border-radius: 5%; border:none;" method="post" class="pl-5 ml-5 m-3">
                    <!-- 编号 -->
                    <div class="form-group row pt-3">
                       <label for="uid" class="offset-md-1 col-md-2 pt-2">用户编号:</label>
                       <!-- v-model="user.uid"将数据绑定到user这个对象的uid值中 -->
                       <input type="text" class="form-control col-md-7" v-model="user.uid" name="uid" id="uid" 
                                   aria-describedby="helpId" placeholder="请输入用户编号" style="background-color: transparent;border: 1px solid black;">
                   </div>
                   <!-- 账号 -->
                   <div class="form-group row">
                       <label for="uname" class="offset-md-1 col-md-2 pt-2">账号:</label>
                       <input type="text" class="form-control col-md-7" v-model="user.uname" name="uname" id="uname" 
                                   aria-describedby="helpId" placeholder="请输入账号" style="background-color: transparent;border: 1px solid black;">
                   </div>
                   <!-- 密码 -->
                   <div class="form-group row">
                    <label for="password" class="offset-md-1 col-md-2 pt-2">密码:</label>
                    <input type="text" class="form-control col-md-7" v-model="user.password" name="password" id="password" 
                                aria-describedby="helpId" placeholder="请输入密码" style="background-color: transparent;border: 1px solid black;">
                </div>

                  
                   
                   <div class="row pb-3">
                       <button type="button" @click="add()"  class="offset-md-1 col-md-9 btn btn-info btn-lg btn-block">添加用户</button>
                   </div>
               </form>
               
                <!-- 所有用户展示 -->
                <table class="table table-bordered" id="tab">
                    <thead>
                        <tr style="border: 1px solid black;">
                            <th style="border: 1px solid black;">编号</th>
                            <th style="border: 1px solid black;">账号</th>
                            <th style="border: 1px solid black;">密码</th>
                            <th style="border: 1px solid black;">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr v-for="(sta, index) in users" :key="index" style="border: 1px solid black;">
                            <td style="border: 1px solid black;">{{sta.uid}}</td>
                            <td style="border: 1px solid black;">{{sta.uname}}</td>
                            <td style="border: 1px solid black;">{{sta.password}}</td>
                            
                            <td style="border: 1px solid black;">
                                <button v-if="sta.status==0" class="btn btn-danger" type="button" @click="users.splice(index,1)" style="background-color: #12a4ba;">删除</button>
                                
                            </td>
                        </tr>
                    </tbody>
                </table>

           </div>
          
       </div>
   </div>


   <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
   <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
 </body>
</html>
<script>
   new Vue({
       el:"#app",
       data() {
           return {
               users:users,
               user:{uid:"",uname:"",password:"",status:0},//一个用户
           }
       },
       methods: {
           add(){
               let flag = true;
               let msg = "";
               if(this.user.uid==""){
                   flag = false;
                   msg = "用户编号没有输入，请输入";
               }
               if(this.user.uname==""){
                   flag = false;
                   msg = "用户账号没有输入，请输入";
               }
               if(this.user.password==""){
                   flag = false;
                   msg = "用户密码没有输入，请输入";
               }
               
               if(flag){
                   alert(flag);
                   this.users.push(this.user);
                   this.clear();
               }else{
                   confirm(msg);
               }
           },
           clear(){
               this.user={uid:"",uname:"",passsword:"",status:0};
           }
       },
   })
</script>